pub struct Submodule<'repo> { /* private fields */ }attributes only.Expand description
A stand-in for the submodule of a particular name.
Implementations§
Source§impl Submodule<'_>
impl Submodule<'_>
Sourcepub fn status(&self, ignore: Ignore, check_dirty: bool) -> Result<Status, Error>
Available on crate feature status only.
pub fn status(&self, ignore: Ignore, check_dirty: bool) -> Result<Status, Error>
status only.Return the status of the submodule.
Use ignore to control the portion of the submodule status to ignore. It can be obtained from
submodule configuration using the ignore() method.
If check_dirty is true, the computation will stop once the first in a ladder operations
ordered from cheap to expensive shows that the submodule is dirty.
Thus, submodules that are clean will still impose the complete set of computation, as given.
Sourcepub fn status_opts(
&self,
ignore: Ignore,
check_dirty: bool,
adjust_options: &mut dyn for<'a> FnMut(Platform<'a, Discard>) -> Platform<'a, Discard>,
) -> Result<Status, Error>
Available on crate feature status only.
pub fn status_opts( &self, ignore: Ignore, check_dirty: bool, adjust_options: &mut dyn for<'a> FnMut(Platform<'a, Discard>) -> Platform<'a, Discard>, ) -> Result<Status, Error>
status only.Return the status of the submodule, just like status, but allows to adjust options
for more control over how the status is performed.
If check_dirty is true, the computation will stop once the first in a ladder operations
ordered from cheap to expensive shows that the submodule is dirty. When checking for detailed
status information (i.e. untracked file, modifications, HEAD-index changes) only the first change
will be kept to stop as early as possible.
Use &mut std::convert::identity for adjust_options if no specific options are desired.
A reason to change them might be to enable sorting to enjoy deterministic order of changes.
The status allows to easily determine if a submodule has changes.
Source§impl Submodule<'_>
Access
impl Submodule<'_>
Access
Sourcepub fn path(&self) -> Result<Cow<'_, BStr>, Error>
pub fn path(&self) -> Result<Cow<'_, BStr>, Error>
Return the path at which the submodule can be found, relative to the repository.
For details, see gix_submodule::File::path().
Sourcepub fn url(&self) -> Result<Url, Error>
pub fn url(&self) -> Result<Url, Error>
Return the url from which to clone or update the submodule.
This method takes into consideration submodule configuration overrides.
Sourcepub fn update(&self) -> Result<Option<Update>, Error>
pub fn update(&self) -> Result<Option<Update>, Error>
Return the update field from this submodule’s configuration, if present, or None.
This method takes into consideration submodule configuration overrides.
Sourcepub fn branch(&self) -> Result<Option<Branch>, Error>
pub fn branch(&self) -> Result<Option<Branch>, Error>
Return the branch field from this submodule’s configuration, if present, or None.
This method takes into consideration submodule configuration overrides.
Sourcepub fn fetch_recurse(&self) -> Result<Option<FetchRecurse>, Error>
pub fn fetch_recurse(&self) -> Result<Option<FetchRecurse>, Error>
Return the fetchRecurseSubmodules field from this submodule’s configuration, or retrieve the value from fetch.recurseSubmodules if unset.
Sourcepub fn ignore(&self) -> Result<Option<Ignore>, Error>
pub fn ignore(&self) -> Result<Option<Ignore>, Error>
Return the ignore field from this submodule’s configuration, if present, or None.
This method takes into consideration submodule configuration overrides.
Sourcepub fn shallow(&self) -> Result<Option<bool>, Error>
pub fn shallow(&self) -> Result<Option<bool>, Error>
Return the shallow field from this submodule’s configuration, if present, or None.
If true, the submodule will be checked out with depth = 1. If unset, false is assumed.
Sourcepub fn is_active(&self) -> Result<bool, Error>
pub fn is_active(&self) -> Result<bool, Error>
Returns true if this submodule is considered active and can thus participate in an operation.
Please see the plumbing crate documentation for details.
Sourcepub fn index_id(&self) -> Result<Option<ObjectId>, Error>
pub fn index_id(&self) -> Result<Option<ObjectId>, Error>
Return the object id of the submodule as stored in the index of the superproject,
or None if it was deleted from the index.
If None, but Some() when calling Self::head_id(), then the submodule was just deleted but the change
wasn’t yet committed. Note that None is also returned if the entry at the submodule path isn’t a submodule.
If Some(), but None when calling Self::head_id(), then the submodule was just added without having committed the change.
Sourcepub fn head_id(&self) -> Result<Option<ObjectId>, Error>
pub fn head_id(&self) -> Result<Option<ObjectId>, Error>
Return the object id of the submodule as stored in HEAD^{tree} of the superproject, or None if it wasn’t yet committed.
If Some(), but None when calling Self::index_id(), then the submodule was just deleted but the change
wasn’t yet committed. Note that None is also returned if the entry at the submodule path isn’t a submodule.
If None, but Some() when calling Self::index_id(), then the submodule was just added without having committed the change.
Sourcepub fn git_dir(&self) -> PathBuf
pub fn git_dir(&self) -> PathBuf
Return the path at which the repository of the submodule should be located.
The directory might not exist yet.
Sourcepub fn work_dir(&self) -> Result<PathBuf, Error>
pub fn work_dir(&self) -> Result<PathBuf, Error>
Return the path to the location at which the workdir would be checked out.
Note that it may be a path relative to the repository if, for some reason, the parent directory doesn’t have a working dir set.
Sourcepub fn git_dir_try_old_form(&self) -> Result<PathBuf, Error>
pub fn git_dir_try_old_form(&self) -> Result<PathBuf, Error>
Return the path at which the repository of the submodule should be located, or the path inside of the superproject’s worktree where it actually is located if the submodule in the ‘old-form’, thus is a directory inside of the superproject’s work-tree.
Note that ‘old-form’ paths returned aren’t verified, i.e. the .git repository might be corrupt or otherwise
invalid - it’s left to the caller to try to open it.
Also note that the returned path may not actually exist.
Sourcepub fn state(&self) -> Result<State, Error>
pub fn state(&self) -> Result<State, Error>
Query various parts of the submodule and assemble it into state information.
Sourcepub fn open(&self) -> Result<Option<Repository>, Error>
pub fn open(&self) -> Result<Option<Repository>, Error>
Open the submodule as repository, or None if the submodule wasn’t initialized yet.
More states can be derived here:
- initialized - a repository exists, i.e.
Some(repo)and the working tree is present. - uninitialized - a repository does not exist, i.e.
None - deinitialized - a repository does exist, i.e.
Some(repo), but its working tree is empty.
Also see the state() method for learning about the submodule.
The repository can also be used to learn about the submodule HEAD, i.e. where its working tree is at,
which may differ compared to the superproject’s index or HEAD commit.